Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deterministic cycle keys #1520

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Deterministic cycle keys #1520

wants to merge 1 commit into from

Conversation

jg-rp
Copy link
Contributor

@jg-rp jg-rp commented Feb 14, 2022

This pull request fixes #1519 by offering an alternative method for generating context keys for the cycle tag when using "simple syntax".

Rather than using a string representation of objects returned from parse_expression(), we combine the object's class name and input argument, separated by a hyphen.

For example, given a identifier that gets parsed to a Liquid::VariableLookup, instead of a key containing something like "<Liquid::VariableLookup:0x00005632631bc858>", which changes with every occurrence of {% cycle %}, we would get "VariableLookup-x". Where x is the input argument.

Extra care has been taken to handle Liquid::C::Expression objects. Hence the use of object.respond_to?(:evaluate) and the reason for generating key strings at the same time as parsing each expression.

@ghost ghost added the cla-needed label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cycle context variables
1 participant